home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Epic Collection 3
/
Epic Collection 3, The (1997)(Epic Marketing)[!].iso
/
internet
/
ums
/
ums11.6
/
rexx
/
mailforwarder.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1996-09-08
|
4KB
|
166 lines
/*
*$VER: UMS MailForwarder V1.1
*
*Forward mails width UMS. You *must* read mailforwarder.doc
*to use this.
*
*Author: Stefan Sticht, sticht@edith.deg.sub.org, 2:2494/22.4@fidonet
*History: V1.0 03 Jan 94 Sticht first version
*History: V1.1 27 Jul 94 hG · use UMSInit.rexx and hgrexxsupport.library
*History: · template according LoginGuide
*History: · copies msg no longer, just changes some fields
*History: v1.2 25 Jan 95 hG adapted to UMS V11
*
*/
/*** Startup ***/
ReplyName = "Mail-Daemon"; ReplyPassword = "";
ProgramName = "MailForwarder";
ArgsTemplate = "Name,Password,Server/K"
call addlib("hgrexxsupport.library",0,-30);
interpret include("ums:s/UMSInit.rexx")
if rc ~= 0 then do
say "cannot read UMS include-file!"
exit 20
end
/*** Login ***/
/*
* login as user
*/
account = UMSLogin(Name, Password, Server)
IF account = 0 THEN DO
SAY "unable to login as user '" || Name || "'!"
EXIT
END
/*
* login as importer "mailforwarder", too
*/
faccount = UMSLogin(ReplyName, ReplyPassword)
IF faccount ~= 0 THEN DO
Empty_Flags = MakeFlags()
FLAG_0 = MakeFlags(0)
FLAG_1 = MakeFlags(1)
FLAGS_01 = MakeFlags(0,1)
Mask = MakeFlags(UMSUSTAT_ViewAccess, UMSUSTAT_Old)
Match = MakeFlags(UMSUSTAT_ViewAccess)
/*
* read our config vars for this user
*/
toaddr = UMSReadConfig(account, "mailforwarder.toaddr", Name, 0)
toname = UMSReadConfig(account, "mailforwarder.toname", Name, 0)
IF toname ~= "" THEN DO
/*
* select all new mails for this account
*
* set local flag 0 on all new messages
*/
CALL UMSSelectFlags(account, "L", FLAG_0, Empty_Flags,,, "U", Mask, Match)
/*
* set local flag 1 on all mails
*/
CALL UMSSelectField(account, "L", FLAG_1, Empty_Flags,,, UMSCODE_Group, "", TRUE)
/*
* main loop: read, convert and write all unread messages
*/
last = 0
msgs = 0
DO FOREVER
/*
* find next message with local flags 0 and 1 set
*/
last = UMSSearchFlags(account, "LOCAL", FLAGS_01, FLAGS_01, last)
IF last = 0 THEN LEAVE
/*
* read message
*/
DROP msg.
IF UMSReadMsgAll(account, last, msg.) THEN DO
IF UMSReadMsgInfo(account, last, msg.) THEN DO
/*
* convert message
*/
msg.UMSCODE_ToName = toname
IF toaddr ~= "" THEN msg.UMSCODE_ToAddr = toaddr
ELSE drop msg.UMSCODE_ToAddr
msg.hardlink = last
/*
* write message
*/
IF UMSWriteMsg(faccount, msg.) = 0 THEN CALL CheckErr(faccount)
ELSE msgs = msgs + 1
END
ELSE CALL CheckErr(account)
END
ELSE CALL CheckErr(account)
END /* DO FOREVER */
/*
* display a short report
*/
IF msgs > 0 THEN SAY "Forwarded" msgs "mail(s) to" toname || "."
ELSE SAY "Nothing to forward."
END
ELSE DO
SAY "No mailforwarder installed for this user!"
END
END
ELSE DO
SAY "Unable to login as user 'mailforwarder'!"
SAY "Check your configuration!"
END
/*** Final cleanup ***/
BREAK_C:
BREAK_D:
BREAK_E:
BREAK_F:
ERROR:
HALT:
IOERR:
SYNTAX:
IF RC ~= 0 THEN DO
SAY "Error:" rc ERRORTEXT(rc) "in line" sigl
END
/*** Logout ***/
IF faccount ~= 0 THEN DO
CALL UMSLogout(faccount)
faccount = 0
END
IF account ~= 0 THEN DO
CALL UMSLogout(account)
account = 0
END
EXIT
/*** Support ***/
CheckErr: PROCEDURE
PARSE ARG account
err = UMSErrNum(account)
IF err ~= 0 THEN DO
SAY "UMS Error #" || err || ": " || UMSErrTxt(account)
END
RETURN